package com.lyf.language.learn.atsgg.java8.streamapi;

import org.junit.Test;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @AUTHOR LYF
 * @DATE 2022/6/6
 * @VERSION 1.0
 * @DESC
 */
public class StreamAPITests {


    @Test
    public void test1(){

        List<Person> list =new LinkedList<>();
        Stream.iterate(0,e->e+1).limit(10).forEach(System.out::println);
        list.add(new Person("李云飞",22,4550.0));
        list.add(new Person("史可心",21,4300.0));
        list.add(new Person("张君",22,5555.0));

        // 1.创建获取Stream---
        // 2.中间操作-- map,sorted,limit,match
        // 3.终止操作 -- foreach,reduce,max,min,count
        List<Double> list1 = list.stream().map(Person::getSalary). //理解引用方法---保持参数和方法体的一致
                sorted(Double::compareTo).
                collect(Collectors.toList());
        list1.forEach(System.out::println);


    }
}
